package com.vietnam.power.persistence;

import java.io.Serializable;

import javax.persistence.*;

import org.hibernate.annotations.Type;

import com.vietnam.power.dao.IAuditTable;

import java.util.Date;

/**
 * The persistent class for the chat_message database table.
 * 
 */
@Entity
@Table(name = "chat_message")
public class ChatMessage implements Serializable, IAuditTable {
	private static final long serialVersionUID = 1L;
	private Long chatMessageId;
	private Date createdDate;
	private String description;
	private ProductChat productChat;
	private UserInfo createdBy;
	private File file;
	private boolean read;

	public ChatMessage() {
	}

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "CHAT_MESSAGE_ID")
	public Long getChatMessageId() {
		return this.chatMessageId;
	}

	public void setChatMessageId(Long chatMessageId) {
		this.chatMessageId = chatMessageId;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "CREATED_DATE")
	public Date getCreatedDate() {
		return this.createdDate;
	}

	public void setCreatedDate(Date createdDate) {
		this.createdDate = createdDate;
	}

	public String getDescription() {
		return this.description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	// bi-directional many-to-one association to ProductChat
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "PRODUCT_CHAT_ID")
	public ProductChat getProductChat() {
		return this.productChat;
	}

	public void setProductChat(ProductChat productChat) {
		this.productChat = productChat;
	}

	// bi-directional many-to-one association to File
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "FILE_ID")
	public File getFile() {
		return this.file;
	}

	public void setFile(File file) {
		this.file = file;
	}

	@Override
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "CREATED_BY")
	public UserInfo getCreatedBy() {
		return this.createdBy;
	}

	@Override
	public void setCreatedBy(UserInfo createdBy) {
		this.createdBy = createdBy;		
	}

	@Type(type="true_false")
	public boolean getRead() {
		return read;
	}

	public void setRead(boolean read) {
		this.read = read;
	}

}